<template>
  <div>
    <el-divider content-position="left">基本信息</el-divider>
    <el-form ref="form" :model="form" label-width="80px">
      <table class="table">
        <tbody>
        <tr>
          <td class="k">用户名</td>
          <td class="v">{{info.username}}</td>
          <td class="k">性别</td>
          <td class="v">{{info.sex}}</td>
          <td class="k">电话</td>
          <td class="v">{{info.telnumber}}</td>
        </tr>
        </tbody>
      </table>
    </el-form>


    <br><br><br><br><hr><br><br><br><br>
    <div class="formdiv">
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="旧密码">
          <el-input  v-model="form.oldPwd" maxlength="6" show-word-limit  clearable show-password></el-input>
        </el-form-item>
        <el-form-item label="新密码">
          <el-input  v-model="form.newPwd" maxlength="6" show-word-limit  clearable show-password></el-input>
        </el-form-item>
        <el-button type="primary" @click="updatePassword">点击修改</el-button>
      </el-form>
    </div>

  </div>


</template>

<script>

import {qryInfo,updatePassword} from "@/network/info";

var token = localStorage.getItem('Authorization')

export default {
  data () {
    return {
      info: {

      },
      form: {
        oldPwd: '',
        newPwd: ''
      },
      myHeaders: {Authorization: token}
    }
  },
  methods: {
    qryInfo () {
      qryInfo().then(res => {
        console.log(res)
        this.info = res.data
      })
    },
    updatePassword () {
      updatePassword(this.form.oldPwd,this.form.newPwd).then(res => {
        console.log(res)
        if (res.code == '30000') {
          this.$message.success(res.message);
          this.$message('修改成功')
          // this.$router.push("/form/login");
        } else {
          this.$message(res.message);
        }
      });
    }
  },
  created() {
    this.qryInfo()
  }
}
</script>

<style scoped>
.formdiv {
  width: 400px;
  margin: 0 auto;
  text-align: center;
}
.el-main {
  /*background: #eee;*/
  color: #333;
  width: 1000px;
  margin: 0 auto;
}

.table {
  width: 900px;
  margin: 0 auto;
  color: #838383 !important;
  margin-bottom: 50px;
}

.table tr {
  height: 45px;
}

.table td {
  border-left: 1px solid #ededed;
  border-top: 1px solid #ededed;
}

.table .k {
  width: 20%;
  text-align: right;
}

.table .v {
  width: 30%;
  padding-left: 20px;
}

.table {
  border-right: 1px solid #ededed;
  border-bottom: 1px solid #ededed;
}

/*奇数变色*/
.table tr:nth-child(odd) {
  background: rgb(249, 249, 249);
}

.formdiv {
  width: 400px;
  margin: 0 auto;
  text-align: center;
}

.headerimg {
  height: 80px;
  width: 80px;
  margin: 0 auto;
  margin-bottom: 10px;
}

</style>
